/**
 *
 */
package jp.seraph.jsade.sexpression;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.Reader;
import java.net.SocketAddress;

import jp.seraph.jsade.net.RoboCupSocket;

/**
 *
 *
 */
public class DummySocket implements RoboCupSocket {
    public DummySocket(Reader aReader){
        mReader = new BufferedReader(aReader);
    }

    private BufferedReader mReader;

    /**
     *
     * @see jp.seraph.jsade.net.RoboCupSocket#close()
     */
    public void close() {
    }

    /**
     *
     * @see jp.seraph.jsade.net.RoboCupSocket#connect(java.net.SocketAddress)
     */
    public void connect(SocketAddress aAddress) throws IOException {
    }

    /**
     *
     * @see jp.seraph.jsade.net.RoboCupSocket#read()
     */
    public String read() throws IOException {
        String tResult = mReader.readLine();
        if(tResult == null){
            this.notify();
            return "";
        }
        return tResult;
    }

    /**
     *
     * @see jp.seraph.jsade.net.RoboCupSocket#write(java.lang.String)
     */
    public int write(String aData) throws IOException {
        return aData.getBytes().length + 4;
    }
}
